<meta charset="UTF-8">
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
        <?php
        // put your code here
        session_start();
        
        /**
         * @todo 文本框添加placeholder属性
         * @todo 修改元素与元素之间的间距
         * @todo 输入数字时指定输入区间及增长量
         * @todo 添加、修改信息时区分必要信息和非必要信息，在提交时针对所填非必要信息为空作相应的特殊处理
         * @todo 对输入的信息进行限制及检查
         * @todo 针对空值在界面显示"暂无XX"
         * @todo 插入信息成功后弹出提示操作成功的窗口
         * @todo 删除信息前弹出窗口确认
         * @todo 后台添加图片与前台显示图片大小一致
         * @todo 对复制粘贴后的代码进行去重调整
         * @todo 修改所有页面的title
         * @todo 对所有页面警告信息的处理
         * @todo 页面美化，并引入图片
         * @todo 密码加密后存入数据库
         * @todo 完善源文件中的注释
         * @todo 首页最新上架部分使用循环语句重构
         * @todo 后台管理使用session
         * 
         * @remark 说实话，相比较于当时专科的毕业设计，这个设计前后台一整套做下来，心里面一点谱都没有。
         *          一开始在进行技术选型的时候就踩了一个坑，php应该与mysql配合使用的，而我却选了mssql。
         *          完成设计的过程中，自己的前端底子太弱，后端又没有什么技术含量，也就是CRUD的操作。
         *          整个项目中感觉技术相对来说最复杂的也许就是SQL语句了。
         *          前端感觉自己也没办法去怎么美化了，自己也考虑过使用现成的前端框架
         *          但是考虑到工作量以及时间，还是放弃了。
         *          全组的8个人，几乎没几个自己真正写的，跟包盈盈的班里的几个人只有吉雨是自己基于现买的系统然后自己再改改的。
         *          整个项目还有很多的地方还没有真正设计好，例如，检查用户的输入，对边界值的检查等。
         *          许多源文件中留了各种todo标签，估计再也不会去do了...
         *          不过，自己在完成整个毕业设计的过程中也收获了不少。
         *          主要就是熟悉了一下Web开发，了解了后端语言如何与前端语言进行交互等。
         *          最后，希望老师不要再提新的需求了，我也不想再改了(主要还是自己的代码写的太乱了)...
         */
        ?>
    <table width="100%" height="500" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#B0E0E6"><?php include("top.php");?></td>
  </tr>
  <tr>
    <td><table width="766" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="209" valign="top" bgcolor="#F5F5F5">
            <?php include("left.php");?>
        </td>
        <td width="557" height="438" align="center" valign="top" bgcolor="#F5F5F5"><table width="557"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="553" bgcolor="#FFFFFF"><table width="548" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="557"  height="50"></td>
                </tr>
              </table>

                <table width="543" height="450" border="00" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                      <td height="20"><div align="right"><a href="shownewbook.php">最新上架</a></div></td>
                  </tr>
                  <tr>
                    <td width="543" height="110"><table width="540" height="110" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="265">
                            <?php
			  $sql= exectue_sql_statement($conn, "select top 2 Book.book_id, book_name, book_introduction, unit_price, book_img, book_amount from Book, Store where Book.book_id=Store.book_id order by Book.book_id desc");
			  $info=sqlsrv_fetch_array($sql);
			  if($info==false){
			   echo "暂无图书!";
			  }
			  else{
			  ?>
                            <table width="270"  border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="130" rowspan="5"><div align="center">
                                    <?php
				    if(trim($info['book_img']=="")){
					  echo "暂无图片";
					}
					else{
				  ?>
                                    <img src="<?php echo $info['book_img'];?>" width="150" height="150" border="0">
                                    <?php
				     }
				  ?>
                                </div></td>
                                <td width="11" height="16">&nbsp;</td>
                                <td width="124">&nbsp;<?php echo $info['book_name'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>售价：￥<?php echo $info['unit_price'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>剩余数量：
                                  <?php 
				  if($info['book_amount']>0)
				  {
				     echo $info['book_amount'];
				  }
				  else
				  {
				     echo "已售完";
				  }
				  ?>
                                </td>
                              </tr>
                              <tr>
                                  <td height="30" colspan="2"><a href="bookinfo.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="详细信息" width="60" height="18" border="0"></a> <a href="addtocart.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="购买" width="60" height="18" border="0"></a> </td>
                              </tr>
                            </table>
                            <?php
				}
                            ?>
                          </td>
                          <td width="265">
                            <?php
			  $info=sqlsrv_fetch_array($sql);
			  if($info==false){
                            /**
                             * @remark 这就是复制粘贴的后果
                             */
			   //echo "本站暂无图书!";
			  }
			  else{
			  ?>
                            <table width="270"  border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="130" rowspan="5"><div align="center">
                                    <?php
				    if(trim($info['book_img']=="")){
					  echo "暂无图片";
					}
					else{
				  ?>
                                    <img src="<?php echo $info['book_img'];?>" width="150" height="150" border="0">
                                    <?php
				     }
				  ?>
                                </div></td>
                                <td width="11" height="16">&nbsp;</td>
                                <td width="124">&nbsp;<?php echo $info['book_name'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>售价：￥<?php echo $info['unit_price'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>剩余数量：
                                  <?php 
				  if($info['book_amount']>0)
				  {
				     echo $info['book_amount'];
				  }
				  else
				  {
				     echo "已售完";
				  }
				  ?>
                                </td>
                              </tr>
                              <tr>
                                  <td height="30" colspan="2"><a href="bookinfo.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="详细信息" width="60" height="18" border="0"></a> <a href="addtocart.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="购买" width="60" height="18" border="0"></a> </td>
                              </tr>
                            </table>
                            <?php
				}
                            ?>
                          </td>
                        </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td width="543" height="110"><table width="540" height="110" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="265">
                            <?php
			  $sql= exectue_sql_statement($conn, "select top 2 Book.book_id, book_name, book_introduction, unit_price, book_img, book_amount from Book, Store where Book.book_id=Store.book_id and Book.book_id not in(select top 2 Book.book_id from Book order by Book.book_id desc) order by Book.book_id desc");
			  $info=sqlsrv_fetch_array($sql);
			  if($info==false){
			   //echo "暂无图书!";
			  }
			  else{
			  ?>
                            <table width="270"  border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="130" rowspan="5"><div align="center">
                                    <?php
				    if(trim($info['book_img']=="")){
					  echo "暂无图片";
					}
					else{
				  ?>
                                    <img src="<?php echo $info['book_img'];?>" width="150" height="150" border="0">
                                    <?php
				     }
				  ?>
                                </div></td>
                                <td width="11" height="16">&nbsp;</td>
                                <td width="124">&nbsp;<?php echo $info['book_name'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>售价：￥<?php echo $info['unit_price'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>剩余数量：
                                  <?php 
				  if($info['book_amount']>0)
				  {
				     echo $info['book_amount'];
				  }
				  else
				  {
				     echo "已售完";
				  }
				  ?>
                                </td>
                              </tr>
                              <tr>
                                  <td height="30" colspan="2"><a href="bookinfo.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="详细信息" width="60" height="18" border="0"></a> <a href="addtocart.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="购买" width="60" height="18" border="0"></a> </td>
                              </tr>
                            </table>
                            <?php
				}
                            ?>
                          </td>
                          <td width="265">
                            <?php
			  $info=sqlsrv_fetch_array($sql);
			  if($info==false){
                            /**
                             * @remark 这就是复制粘贴的后果
                             */
			   //echo "本站暂无图书!";
			  }
			  else{
			  ?>
                            <table width="270"  border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="130" rowspan="5"><div align="center">
                                    <?php
				    if(trim($info['book_img']=="")){
					  echo "暂无图片";
					}
					else{
				  ?>
                                    <img src="<?php echo $info['book_img'];?>" width="150" height="150" border="0">
                                    <?php
				     }
				  ?>
                                </div></td>
                                <td width="11" height="16">&nbsp;</td>
                                <td width="124">&nbsp;<?php echo $info['book_name'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>售价：￥<?php echo $info['unit_price'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>剩余数量：
                                  <?php 
				  if($info['book_amount']>0)
				  {
				     echo $info['book_amount'];
				  }
				  else
				  {
				     echo "已售完";
				  }
				  ?>
                                </td>
                              </tr>
                              <tr>
                                  <td height="30" colspan="2"><a href="bookinfo.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="详细信息" width="60" height="18" border="0"></a> <a href="addtocart.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="购买" width="60" height="18" border="0"></a> </td>
                              </tr>
                            </table>
                            <?php
				}
                            ?>
                          </td>
                        </tr>
                    </table></td>
                  </tr>
                  <!--
                  <tr>
                      <td height="20"><div align="right"><a href="shownewbook.php">最新热销</a></div></td>
                  </tr>
                  <tr>
                    <td width="543" height="110"><table width="540" height="110" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="265">
                            <?php
			  $sql= exectue_sql_statement($conn, "select top 4 Orders.book_id, book_name, book_introduction, unit_price, book_img, book_amount from Book, Orders, Store where Book.book_id=Orders.book_id and Book.book_id=Store.book_id group by Orders.book_id, book_name, book_introduction, unit_price, book_img, book_amount order by sum(orders_amount) desc");
			  $info=sqlsrv_fetch_array($sql);
			  if($info==false){
			   echo "暂无图书!";
			  }
			  else{
			  ?>
                            <table width="270"  border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="130" rowspan="5"><div align="center">
                                    <?php
				    if(trim($info['book_img']=="")){
					  echo "暂无图片";
					}
					else{
				  ?>
                                    <img src="<?php echo $info['book_img'];?>" width="150" height="150" border="0">
                                    <?php
				     }
				  ?>
                                </div></td>
                                <td width="11" height="16">&nbsp;</td>
                                <td width="124">&nbsp;<?php echo $info['book_name'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>售价：￥<?php echo $info['unit_price'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>剩余数量：
                                  <?php 
				  if($info['book_amount']>0)
				  {
				     echo $info['book_amount'];
				  }
				  else
				  {
				     echo "已售完";
				  }
				  ?>
                                </td>
                              </tr>
                              <tr>
                                  <td height="30" colspan="2"><a href="bookinfo.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="详细信息" width="60" height="18" border="0"></a> <a href="addtocart.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="购买" width="60" height="18" border="0"></a> </td>
                              </tr>
                            </table>
                            <?php
				}
                            ?>
                          </td>
                          <td width="265">
                            <?php
			  $info=sqlsrv_fetch_array($sql);
			  if($info==false){
			   //echo "本站暂无图书!";
			  }
			  else{
			  ?>
                            <table width="270"  border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="130" rowspan="5"><div align="center">
                                    <?php
				    if(trim($info['book_img']=="")){
					  echo "暂无图片";
					}
					else{
				  ?>
                                    <img src="<?php echo $info['book_img'];?>" width="150" height="150" border="0">
                                    <?php
				     }
				  ?>
                                </div></td>
                                <td width="11" height="16">&nbsp;</td>
                                <td width="124">&nbsp;<?php echo $info['book_name'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>售价：￥<?php echo $info['unit_price'];?></td>
                              </tr>
                              <tr>
                                <td height="16">&nbsp;</td>
                                <td>剩余数量：
                                  <?php 
				  if($info['book_amount']>0)
				  {
				     echo $info['book_amount'];
				  }
				  else
				  {
				     echo "已售完";
				  }
				  ?>
                                </td>
                              </tr>
                              <tr>
                                  <td height="30" colspan="2"><a href="bookinfo.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="详细信息" width="60" height="18" border="0"></a> <a href="addtocart.php?book_id=<?php echo $info['book_id'];?>"><input type="button" value="购买" width="60" height="18" border="0"></a> </td>
                              </tr>
                            </table>
                            <?php
				}
                            ?>
                          </td>
                        </tr>
                    </table></td>
                    -->
                  </tr>
                  <tr>
                    <td height="10"></td>
                  </tr>
                </table>
</td>
          </tr>
        </table></td>
      </tr>
    </table>    </td>
  </tr>
  <tr>
<td>
<?php
 include("bottom.php");
?></td>
  </tr>
</table>
